package com.wuhainan.beelzebub.controller.system;

import com.wuhainan.beelzebub.entity.system.Language;
import com.wuhainan.beelzebub.service.system.LanguageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <br>Created by 吴海南 on 2017-12-18.
 * <br>星期一 at 下午 12:02.
 */
@RestController
@RequestMapping("api/i18n")
public class LanguageController {
    @Resource
    private LanguageService languageService;

    @RequestMapping("en")
    public Map<String,String> en() {
        return languageService.findAll().stream().collect(
                Collectors.toMap(Language::getField, Language::getEnglish)
        );
    }

    @RequestMapping("zh-CN")
    public Map<String,String> zhCN() {
        return languageService.findAll().stream().collect(
                Collectors.toMap(Language::getField, Language::getChinese)
        );
    }

}
